<template>
  <div class="report-detail">
    <el-button type="primary" icon="el-icon-back" size="small" @click="backAction">返回</el-button>
    <table class="tables">
      <tr>
        <td>聚会主题</td>
        <td>{{dataForm.title}}</td>
      </tr>
      <tr>
        <td>发起人</td>
        <td>{{dataForm.nickName}}</td>
      </tr>
      <tr>
        <td>聚会时间</td>
        <td>{{dataForm.cadddate}}</td>
      </tr>
      <tr>
        <td>聚会地点</td>
        <td>{{dataForm.place}}</td>
      </tr>
      <tr>
        <td>是否提供机票</td>
        <td>
          <span v-if="dataForm.welfare == 0">不提供</span>
          <span v-else-if="dataForm.welfare == 1">提供</span>
          <span v-else></span>
        </td>
      </tr>
      <tr>
        <td>邀请人数</td>
        <td>{{dataForm.count}}</td>
      </tr>
      <tr>
        <td>聚会奖励</td>
        <td>{{dataForm.diamonds}}</td>
      </tr>
      <tr>
        <td>聚会介绍</td>
        <td>{{dataForm.introduce}}</td>
      </tr>
      <tr>
        <td>聚会封面</td>
        <td>
          <!--:with-credentials='true'  :headers='myHeaders' :on-success="handleAvatarSuccess1" :http-request='myUpload'-->
          <div class="w50 avatar-uploader">
            <p>聚会封面</p>
            <el-upload
              class="upload-uploader"
              :action="keyImgUpUrl+'/system/uploadImage'"
              :show-file-list="false"
              :on-success="handleAvatarSuccess1"
              :before-upload="beforeAvatarUpload"
              >
              <img v-if="pagephoto" :src="pagephoto" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
          <div class="w50 avatar-uploader">
            <p>聚会详情</p>
            <el-upload
              class="upload-uploader"
              :action="keyImgUpUrl+'/system/uploadImage'"
              :show-file-list="false"
              :on-success="handleAvatarSuccess2"
              :before-upload="beforeAvatarUpload">
                <img v-if="detailsphoto" :src="detailsphoto" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
        </td>
      </tr>
      <tr>
        <td>审核</td>
        <td colspan="2">
          <el-radio-group v-model="type" class='tac'>
            <el-radio label="1" v-model="type" value="1">取消见面聚会</el-radio>
          </el-radio-group>
        </td>
      </tr>
    </table>
    <div class="btn">
      <el-button type="primary" @click="getAction">确认</el-button>
    </div>
  </div>
</template>*

<script>
  var token =  sessionStorage.getItem('tata_token') // 要保证取到
  import request from 'axios'
  import {
    partyInfo,
    editParty,
    clickOneParty
  } from '@/request/api';
  export default {
    data() {
      return {
        dataForm: [],
        type: 0,
        pagephoto: '',
        pagephotoUp:'',
        detailsphotoUp:'',
        detailsphoto: '',
        ipartyid:'',
        myHeaders:{Authorization:token}
      }
    },
    created() {
      this.getClickOneParty();
    },
    methods: {
      backAction() {
        this.$router.go(-1);
      },
      getClickOneParty() {
        clickOneParty({
          ipartyid: this.$route.query.ipartyid
        }).then(res => {
          this.dataForm = res.data.data;
          this.pagephoto = res.data.data.pagephoto;
          this.detailsphoto = res.data.data.detailsphoto;
          this.ipartyid = res.data.data.ipartyid;
        })
      },
      getAction() {
        editParty({
          ipartyid: this.$route.query.ipartyid,
          pagephoto: this.pagephoto,
          detailsphoto: this.detailsphoto,
          type: this.type
        }).then(res => {
          if (res.data.code == 200) {
            this.$message({
              message: res.data.message,
              type: "success"
            });
            this.$router.go(-1)
          } else {
            this.$message.error(res.data.message)
          }
        })
      },
      handleAvatarSuccess1(res, file) {
        this.pagephoto = res.data.imageUrl||URL.createObjectURL(file.raw);
      },
      handleAvatarSuccess2(res, file) {
        this.detailsphoto = res.data.imageUrl||URL.createObjectURL(file.raw);
      },
      beforeAvatarUpload(file) {
        var testmsg = /^image\/(jpeg|png|jpg)$/.test(file.type)
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!testmsg) {
          this.$message.error('上传头像图片只能是 JPG ,png 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return testmsg && isLt2M;
      },
    },
};

</script>

<style lang="scss" scoped>
.loading-box{
  width:200px;
  height:200px;
  text-align:center;
  line-height:200px;
  color:#ddd;
  font-size:28px;
  margin:auto;
  border-radius:5px;
  border:1px #ddd dotted;
}
  .report-detail {
    background: #fff;
  }

  .el-button {
    margin: 10px;
    z-index: 9999;
  }

  .tables {
    td {
      padding: 8px 0;
      font-size: 14px;

      &:nth-child(odd) {
        border: 1px #eee solid;
        /* background: #f8f8f8; */
      }

      &:nth-child(even) {
        border: 1px #eee solid;
      }
    }

    tr {
      td:nth-of-type(1) {
        width: 30%;
      }
    }

    tr:last-of-type {
      // height: 400px;
    }

    img {
      width: 300px;
      height: 500px;
      float: left;
      margin: 0 20px;
    }

  }
  .w50{
  width:50%;
  float:left
}
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader{
  img{
    width:200px;
    height:auto;
  }
}
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
<style lang="scss">
  .btn {
    width: 100%;

    .el-button {
      width: 200px;
      height: 80px;
      font-size: 24px;
    }
  }

</style>
